﻿using gt.webapi.core.Entity;
using gt.webapi.core.Entity.Common;
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace gt.webapi.core.Handlers
{
    public class AppkeyHandler: DelegatingHandler
    {
        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var watch = new Stopwatch();
            watch.Start();
            request.Properties.Add(Constants.API_PROPERTY_REQUESTID, Guid.NewGuid().ToString("N"));
            request.Properties.Add(Constants.API_PROPERTY_STOPWATCH, watch);

            return await base.SendAsync(request, cancellationToken);
        }
    }
}
